 <!--
Design by Bryant Smith
http://www.bryantsmith.com
http://www.aszx.net
email: templates [-at-] bryantsmith [-dot-] com
Released under Creative Commons Attribution 2.5 Generic.  In other words, do with it what you please; but please leave the link if you'd be so kind :)

Name       : A Farewell to Colors
Description: One column, with top naviagation
Version    : 1.0
Released   : 20081230
-->


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="style.css" />

<script type="text/javascript">
// Saves options to localStorage.
function save_options() {
  var checkbox_opencomments = document.getElementById("opencomments");
  var checkbox_openvisitedlinks = document.getElementById("openvisitedlinks");
  var checkbox_opennsfwlinks = document.getElementById("opennsfwlinks");
  var checkbox_openlinksdirectly = document.getElementById("openlinksdirectly");
  var input_tabslimit = document.getElementById("tabslimit");
  var input_keyboardshortcut = document.getElementById("keyboardshortcut");
  
  if (isNaN(input_tabslimit.value)){  
	alert("Only Integer for New Tabs Limit !");
	input_tabslimit.value = localStorage["tabslimit"];
	return;
  }
  
  localStorage["opencomments"] = checkbox_opencomments.checked;
  localStorage["openvisitedlinks"] = checkbox_openvisitedlinks.checked;
  localStorage["opennsfwlinks"] = checkbox_opennsfwlinks.checked;
  localStorage["openlinksdirectly"] = checkbox_openlinksdirectly.checked;
  localStorage["tabslimit"] = input_tabslimit.value;
  
  localStorage["oldkeyboardshortcut"] = localStorage["keyboardshortcut"];
  
  localStorage["keyboardshortcut"] = input_keyboardshortcut.value;
  
  var bkg = chrome.extension.getBackgroundPage();
  
  bkg.updateSettings();

  // Update status to let user know options were saved.
  var status = document.getElementById("status");
  status.innerHTML = '<span style="color:#FF0000">Options Saved.</span><br>';
  setTimeout(function() {
    status.innerHTML = "";
  }, 750);
}

// Restores select box state to saved value from localStorage.
function restore_options() {
  var opencomments = localStorage["opencomments"];
  var openvisitedlinks = localStorage["openvisitedlinks"];
  var opennsfwlinks = localStorage["opennsfwlinks"];
  var openlinksdirectly = localStorage["openlinksdirectly"];
  var tabslimit = localStorage["tabslimit"]; 
  var keyboardshortcut = localStorage["keyboardshortcut"];
  
  var checkbox_opencomments = document.getElementById("opencomments");
  var checkbox_openvisitedlinks = document.getElementById("openvisitedlinks");
  var checkbox_opennsfwlinks = document.getElementById("opennsfwlinks");
  var checkbox_openlinksdirectly = document.getElementById("openlinksdirectly");
  var input_tabslimit = document.getElementById("tabslimit");  
  var input_keyboardshortcut = document.getElementById("keyboardshortcut");
  
  checkbox_opencomments.checked = 		(opencomments == "true");
  checkbox_openvisitedlinks.checked = 	(openvisitedlinks == "true");
  checkbox_opennsfwlinks.checked = 		(opennsfwlinks == "true");
  checkbox_openlinksdirectly.checked = 	(openlinksdirectly == "true");
  input_tabslimit.value = 				tabslimit;
  input_keyboardshortcut.value = 		keyboardshortcut;
}

</script>

<title>F7U12 Link Opener - Option Page</title>
</head>

<body onload="restore_options()">
	<div id="page">
		<div id="header">
			<h1>F7U12 Link Opener</h1>
			<h2>Option Page</h2>
		</div>

		<div class="contentText">
			<br>
			<p>Open comments: <input type=checkbox id="opencomments" value="false"></p>
			<p>Open Visited Links: <input type=checkbox id="openvisitedlinks" value="true"></p>			
			<p>Open Links with NSFW in the Title: <input type=checkbox id="opennsfwlinks" value="true"></p>
			<p>Open Links directly (Add .png to all imgur links): <input type=checkbox id="openlinksdirectly" value="false"></p>			
			<p>New Tabs Limit: <input id="tabslimit" type="text" size="30" maxlength="30" value="25"></p>
			<p>Keyboard Shortcut: <input id="keyboardshortcut" type="text" size="30" maxlength="30" value="Ctrl+Shift+f"></p>
			<button onclick="save_options()">Save</button>

			<p id="status"></p>
			
			<a href="changelog.html">Open Changelog</a>
		</div>  
	</div>
	<div id="footer"></div>
</body>
</html>
